<?php
header("Content-Type:text/html;charset=utf-8");//防止网页中文乱码
require 'db_con.php';
 $noteid=isset($_GET['id']) ? $_GET['id']:0;
 if(empty ($_POST))
 {
      $rs=$db->query("select*from tb_note where id='{$noteid}'");
      $k=$rs->fetch_assoc();
      require("edit_html.php");
 }
 else{
 $username=$_REQUEST['username'];
 $content=$_REQUEST['content'];
 date_default_timezone_set('Asia/Shanghai');
 $m_date=date("Y-m-d h:i:s");
 $sql="update tb_note set username='$username',content='$content',m_date='$m_date' where id='{$noteid}'";
//echo $sql;
//exit;
 $rs=$db->query($sql);
 if ($rs==true)
 {
     echo "<script language='javascript' type='text/javascript'>";
     echo "alert('修改成功!');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }
 else{
      echo "<script language='javascript' type='text/javascript'>";
     echo "alert('修改失败!');";
     echo "window.location.href='index.php';";
     echo "</script>";
 }
 }

